package com.lingyuan.ums.controller;

import com.lingyuan.common.core.domain.R;
import com.lingyuan.common.core.domain.vo.ums.MemberAddressVo;
import com.lingyuan.common.core.domain.vo.ums.MemberVo;
import com.lingyuan.common.core.exception.ServiceException;
import com.lingyuan.ums.service.MemberAddressService;
import com.lingyuan.ums.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName：MemberController
 * @Author: LeiHao
 * @Date: 2024/9/21 11:53
 * @Description: 会员信息控制层
 */
@RestController
@RequestMapping("member")
public class MemberController {

    @Autowired
    private MemberService memberService;


    /* *
     * @Title: findById
     * @Author: DELL
     * @Date: 2024-09-21 28:06:56
     * @Params: [id]
     * @Return: R<MemberVo>
     * @Description: 根据id查询会员收货地址
     */
    @GetMapping("findMemberById/{id}")
    public R<MemberVo> findMemberById(@PathVariable Long id){
        if (id == null||id<=0){
            throw new ServiceException("参数错误");
        }
        MemberVo memberVo = memberService.findMemberById(id);
        return R.ok(memberVo,"查询成功");
    }


    /* *
     * @Title: findByUserName
     * @Author: DELL
     * @Date: 2024-09-23 14:24:57
     * @Params: [username]
     * @Return: R<MemberVo>
     * @Description: 用户名查询用户信息
     */
    @GetMapping("findByUserName/{username}")
    public R<MemberVo> findByUserName(@PathVariable String username){
        MemberVo memberVo = memberService.findByUserName(username);
        return R.ok(memberVo,"查询成功");
    }

}
